home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / gfxfx / mp2.pas < prev    next >
Pascal/Delphi Source File  |  1994-06-22  |  2KB  |  80 lines

  1.  
  2. program midiplayer_version2;
  3. { Improved version of random-midi-player, by Bas van Gaalen, Holland, PD }
  4. { Play with this if you have midiplay from ultrasound or whatever... }
  5. uses
  6.   memory,crt,dos;
  7.  
  8. const
  9.   maxnames=99;
  10.  
  11. type
  12.   str12=string[12];
  13.   namesarray=array[0..maxnames] of str12;
  14.   numsarray=array[0..maxnames] of byte;
  15.  
  16. var
  17.   names:namesarray;
  18.   nums:numsarray;
  19.   dirinfo:searchrec;
  20.   time:longint;
  21.   hr,mn,sc,hs:word;
  22.   i,max,cur:byte;
  23.  
  24. function lz(w:word):str12;
  25. var s:str12;
  26. begin
  27.   str(w:0,s); while length(s)<2 do s:='0'+s;
  28.   lz:=s;
  29. end;
  30.  
  31. function convtotime(tm:longint):str12;
  32. var tmpstr1:str12;
  33. begin
  34.   tmpstr1:=lz(tm div 3600)+':';
  35.   tm:=tm-3600*(tm div 3600);
  36.   tmpstr1:=tmpstr1+lz(tm div 60)+':';
  37.   tm:=tm-60*(tm div 60);
  38.   tmpstr1:=tmpstr1+lz(tm);
  39.   convtotime:=tmpstr1;
  40. end;
  41.  
  42. begin
  43.   checkbreak:=true;
  44.   randomize;
  45.   i:=0;
  46.   findfirst('*.MID',archive,dirinfo);
  47.   while (doserror=0) and (i<=maxnames) do begin
  48.     names[i]:=dirinfo.name;
  49.     inc(i);
  50.     findnext(dirinfo);
  51.   end;
  52.   if i=0 then begin
  53.     writeln('No midi-files found in current directory...');
  54.     halt;
  55.   end;
  56.   max:=i;
  57.   fillchar(nums,sizeof(nums),0);
  58.   for i:=0 to max-1 do begin
  59.     cur:=random(max);
  60.     while nums[cur]<>0 do cur:=(1+cur) mod max;
  61.     nums[cur]:=i+1;
  62.   end;
  63.   i:=0;
  64.   repeat
  65.     cur:=nums[i]-1;
  66.     writeln('Loading: (',i+1,'/',max,') ',names[cur],' (',cur+1,')');
  67.     gettime(hr,mn,sc,hs);
  68.     time:=sc+60*mn+3600*hr;
  69.     setmemtop(heapptr);
  70.     swapvectors;
  71.     exec(getenv('comspec'),'/c C:\ULTRASND\PLAYMIDI.EXE '+names[cur]);
  72.     swapvectors;
  73.     setmemtop(heapend);
  74.     gettime(hr,mn,sc,hs);
  75.     time:=(sc+60*mn+3600*hr)-time;
  76.     writeln('Played: ',names[cur],' (',cur+1,')  Playing time: ',convtotime(time));
  77.     inc(i);
  78.   until (i=max) or keypressed;
  79. end.
  80.